home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
8bitfiles.net/archives
/
archives.tar
/
archives
/
compuserve-file-archive
/
05 Programming
/
SHLRAM.SDA
/
NEWCC.A
< prev
next >
Wrap
Text File
|
2019-04-13
|
7KB
|
537 lines
;
; NEWCC.A
; - SOURCE FOR ╨OWER ├ ├OMPILER DRIVER
;
; ┴DRIAN ╨EPPER, ═ARCH 8, 1988
;
.REF ARGSTK
.REF SYSDEV
.REF SYSDRV
.REF WRKDEV
.REF WRKDRV
;
.REF SETLFS
.REF SETNAM
.REF OPEN
.REF CLOSE
.REF CHKIN
.REF CHKOUT
.REF CLRCHN
.REF CHRIN
.REF CHROUT
.REF READST
.REF LOAD
.REF GETIN
;
;
RAMDISK = 1 ;; NON-ZERO ASSEMBLES RAMDISK VERSION
;
; * = $1800 ;; USE LINK -S $1800
;
; LINK -S $1800
;> NEWCC.O
;> USRPROG.O
;> C64KERNAL.O
;>
;
USRPROG JMP START
JMP OPNSRC
START LDA #1
STA PFLAG ; DEFAULT PROMPT FOR DISKS
LDA #'R ; DEFAULT "REGISTER" VARS
STA $03FF
ARGLP DEC ARGSTK
BEQ USAGE ; SHOULDN'T END WITH AN OPTION
CLC
LDA ARGSTK+2
ADC #2
STA ARGSTK+2
STA $4B
LDA ARGSTK+3
ADC #0
STA ARGSTK+3
STA $4C
T0100F LDY #1
LDA ($4B),Y
STA $4E
DEY
LDA ($4B),Y
STA $4D
LDA ($4D),Y
CMP #'-
BNE NODASH
DASHLP INY
LDA ($4D),Y
BEQ ARGLP
CMP #'P
BNE T0200F
LDA #0 ; DON'T PROMPT DISK CHANGES
STA PFLAG
JMP DASHLP
T0200F CMP #'A
BNE T0210F
STA $03FF
JMP DASHLP
T0210F CMP #'S
BNE USAGE
STA $03FF
JMP DASHLP
;
USAGE LDX #<SUSAGE
LDY #>SUSAGE
OUTSTR STX $4B
STY $4C
LDY #0
T0240B LDA ($4B),Y
BEQ T0250F
JSR CHROUT
INY
BNE T0240B
T0250F RTS
;
NODASH = * ; ASSERT ARGSTK (COUNT) != 0
T0300F LDY #0
LDX #2
T0310B LDA ($4D),Y
STA SRCNAM,X ;; FILE NAME INCLUDING '\0' IS STORED
BEQ T0320F
INY
INX
BNE T0310B
T0320F STX SRCLEN
DEY
LDA ($4D),Y
CMP #'C
BNE T0330F
DEY
LDA ($4D),Y
CMP #'.
BEQ T0340F
T0330F LDX #<SNCSF
LDY #>SNCSF
JMP OUTSTR
T0340F LDA WRKDRV
CLC
ADC #'0
STA SRCNAM
STA SSTEMP+1
STA STEMP1
STA STEMP2
LDA SYSDRV
ADC #'0
STA SIZERO+1
STA BCMPNAM
STA BTRNNAM
LDA #2
LDX SYSDEV
TAY
JSR SETLFS
LDA #CMPLEN
LDX #<BCMPNAM
LDY #>BCMPNAM
JSR SETNAM
LDA #0
JSR LOAD
BCC DOCOMP
LDX #<SCDNP
LDY #>SCDNP
JMP OUTSTR
DOCOMP LDA WRKDEV
STA $FE
JSR $2000
LDA #2
JSR CLOSE
JSR CLSCMD
LDA $FE
BEQ T0400F
JSR IDISKS
JMP CLSCMD ; AND RETURN TO SHELL
;
T0400F LDX #<SINSCMP
LDY #>SINSCMP
JSR PROMPT
JSR IDISKS
LDA #2
LDX SYSDEV
TAY
JSR SETLFS
LDA #TRNLEN
LDX #<BTRNNAM
LDY #>BTRNNAM
JSR SETNAM
LDA #0
JSR LOAD
BCC DOTRANS
LDX #15
JSR CHKIN
T0410B JSR CHRIN
PHA
JSR CHROUT
PLA
CMP #$0D
BNE T0410B
JSR CLRCHN
LDX #<SCDNP
LDY #>SCDNP
JMP OUTSTR
DOTRANS LDX #<SINSOBJ
LDY #>SINSOBJ
JSR PROMPT
JSR CMDOUT
LDX #<SSTEMP
LDY #>SSTEMP
JSR OUTSTR
JSR RCMDCHN
LDX #15
JSR CHKOUT
LDX SRCLEN
DEX
;
; SCRATCH OLD OBJECT FILE, IF ANY
;
LDA #'O
STA SRCNAM,X
LDA #'S
JSR CHROUT
LDX #<SRCNAM
LDY #>SRCNAM
JSR OUTSTR
LDA #$0D
JSR CHROUT
JSR RCMDCHN
LDA #2
LDX WRKDEV
TAY
JSR SETLFS
LDA #T1LEN
LDX #<STEMP1
LDY #>STEMP1
JSR SETNAM
JSR OPEN ; 2,WORK,2,STEMP1
JSR RCMDCHN
BEQ T0520F
LDX #<SCNOOF
LDY #>SCNOOF
JSR OUTSTR
LDA #2
JSR CLOSE
JMP CLSCMD
;
T0520F LDA #3
LDX WRKDEV
TAY
JSR SETLFS
LDA #T2LEN
LDX #<STEMP2
LDY #>STEMP2
JSR SETNAM
JSR OPEN ; 3,WORK,3,STEMP2
JSR $2000
LDA #3
JSR CLOSE
LDA #2
JSR CLOSE
;
LDA $FE ; 0 INDICATES OKAY RETURN
BEQ CONCAT
JMP SCRTEMP ; AND RETURN TO SHELL
;
;
;
CONCAT = *
.IFEQ RAMDISK,0
JSR CMDOUT
LDA #'C ; CONCATENATE TEMP FILES INTO NEW OBJECT
JSR CHROUT
LDX #<SRCNAM
LDY #>SRCNAM ; NOW SOURCE.O
JSR OUTSTR
LDA #'=
JSR CHROUT
LDX #0
T0610B LDA STEMP2,X
JSR CHROUT
INX
CPX #T2LEN-4
BNE T0610B
LDA #',
JSR CHROUT
LDX #0
T0620B LDA STEMP1,X
JSR CHROUT
INX
CPX #T1LEN-4
BNE T0620B
LDA #$0D
JSR CHROUT
JSR RCMDCHN
LDX #15
JSR CHKOUT
;
.ELSE
;
LDX #<SCATFIL
LDY #>SCATFIL
JSR OUTSTR
LDA #2
LDX WRKDEV
TAY
JSR SETLFS
LDX SRCLEN
LDA #',
STA SRCNAM,X
INX
LDA #'W
STA SRCNAM,X
INX
LDA #0
STA SRCNAM,X
TXA
LDX #<SRCNAM
LDY #>SRCNAM
JSR SETNAM
JSR OPEN ; 2,WORK,2,SRCNAM.O,W
JSR RCMDCHN
BEQ T0620F
LDX #<SCNOOF
LDY #>SCNOOF
JSR OUTSTR
JMP BADCAT
;
T0620F LDA #T2LEN-4
LDX #<STEMP2
LDY #>STEMP2
JSR TCOPY ; COPIES TO 2, USING 3
;
LDA #T1LEN-4
LDX #<STEMP1
LDY #>STEMP1
JSR TCOPY ; COPIES TO 2, USING 3
JMP BADCAT
;
TCOPY = *
JSR SETNAM
LDA #3
LDX WRKDEV
TAY
JSR SETLFS
JSR OPEN ; 3,WORK,3,XXXTEMPN
;
TCOPYLP LDX #3
JSR CHKIN
LDX #<BUFF
LDY #>BUFF
LDA #254
JSR GETBLK
PHA ; SAVE READST
LDX #2
JSR CHKOUT
TYA ; TRANSFER COUNT
LDX #<BUFF
LDY #>BUFF
JSR PUTBLK
PLA ; GET BACK READST
BEQ TCOPYLP
;
JSR CLRCHN
LDA #3
JMP CLOSE ; AND RETURN
;
; GETBLK MAX (X,Y)
;
; RETURNS READST
; Y IS COUNT
;
; C64 KERNAL IS SUCH BLOCK MUST BE
; AT LEAST 1 CHAR
;
GETBLK = *
STX $22
STY $23
STA $24
LDY #0
T0510 JSR CHRIN
STA ($22),Y
INY
JSR READST
BNE T0520
CPY $24
BNE T0510
T0520 RTS
;
;
PUTBLK = *
STX $22
STY $23
STA $24
LDY #0
BEQ T0540
T0530 LDA ($22),Y
JSR CHROUT
INY
T0540 CPY $24
BNE T0530
RTS
;
BADCAT = *
LDA #2
JSR CLOSE
.FI
;
;
JSR SCRTEMP
LDX ARGSTK
DEX
BEQ T0600F
JMP ARGLP
;
T0600F RTS ; RETURN TO SHELL
;
SCRTEMP LDX #15
JSR CHKOUT
LDX #<SSTEMP
LDY #>SSTEMP
JSR OUTSTR
JSR RCMDCHN
LDA #15
JMP CLOSE ; AND RETURN
;
IDISKS JSR CLSCMD
LDX SYSDEV
CPX WRKDEV
BEQ SAMEDEV
LDA #15
TAY
JSR SETLFS
LDA #1
LDX #<SIZERO
LDY #>SIZERO
JSR SETNAM
JSR OPEN
JSR CLSCMD
LDX WRKDEV
SAMEDEV LDA #15
TAY
JSR SETLFS
LDA #1
LDX #<SIZERO
LDY #>SIZERO
JSR SETNAM
JMP OPEN ; AND RETURN
;
; OPEN SOURCE FROM INSIDE COMPILER
;
OPNSRC LDA 1
PHA
ORA #$07
STA 1
CLI
LDX #<SINSSRC
LDY #>SINSSRC
JSR PROMPT
LDA SSTEMP+1
STA SIZERO+1
LDA #15
LDX WRKDEV
TAY
JSR SETLFS
LDA #3
LDX #<SIZERO
LDY #>SIZERO
JSR SETNAM
JSR OPEN
LDA #2
LDX WRKDEV
TAY
JSR SETLFS
LDX #<SRCNAM
LDY #>SRCNAM
LDA SRCLEN
JSR SETNAM
JSR OPEN ;; 2,WORK,2,SRCNAM
BCS T0720F
JSR RCMDCHN
BNE T0720F
CLC
BCC T0730F
T0720F LDA #2
JSR CLOSE
LDX #<SSFNF
LDY #>SSFNF
SEC
T0730F SEI
PLA
STA 1
RTS
RCMDCHN LDX #15
JSR CHKIN
JSR CHRIN
CMP #'0
BNE T0800F
JSR CHRIN
CMP #'0
T0800F PHP
T0810B JSR CHRIN
CMP #$0D
BNE T0810B
JSR CLRCHN
PLP ; FOLLOW WITH BEQ FOR OKAY
RTS
;
CMDOUT LDX #15
JMP CHKOUT ; AND RETURN
;
CLSCMD JSR CLRCHN
LDA #15
JMP CLOSE
;
PROMPT LDA PFLAG
BNE T0900F
RTS
T0900F JSR OUTSTR
T0910B JSR GETIN
CMP #$0D
BNE T0910B
RTS
SUSAGE .BYTE "USAGE: CC [-PAS]"
.BYTE " FILENAME"
.BYTE $0D, $0D, $00
SCDNP .BYTE "COMPILER DISK NOT PRESENT"
.BYTE $0D, $0D, $00
SSFNF .BYTE "SOURCE FILE NOT FOUND"
.BYTE $0D, $0D, $00
SINSSRC .BYTE $0D
.BYTE "INSERT SOURCE DISK"
.BYTE $0D, $0D, $00
SINSCMP .BYTE $0D
.BYTE "INSERT COMPILER DISK"
.BYTE $0D, $00
SINSOBJ .BYTE "INSERT OBJECT DISK"
.BYTE $0D, $0D, $00
SNCSF .BYTE "NOT A ├ SOURCE FILE"
.BYTE $0D, $0D, $00
SCNOOF .BYTE "CAN'T OPEN OBJECT FILE"
.BYTE $0D, $0D, $00
SCATFIL .BYTE $0D
.BYTE "...CONCATENATING OBJECT FILE..."
.BYTE $0D, $00
SIZERO .BYTE "I0:"
.BYTE $0D, $00
SSTEMP .BYTE "S0:XXXTEMP*"
.BYTE $0D, $00
STEMP1 .BYTE "0:XXXTEMP1,S,W"
T1LEN = *-STEMP1
.BYTE $00
STEMP2 .BYTE "0:XXXTEMP2,S,W"
T2LEN = *-STEMP2
.BYTE $00
BCMPNAM .BYTE "0:COMPILER"
CMPLEN = *-BCMPNAM
BTRNNAM .BYTE "0:TRANSLATOR"
TRNLEN = *-BTRNNAM
SRCLEN .BYTE $00
SRCNAM .BYTE "0:"
.BSS 22
PFLAG .BSS 1
BUFF = *